package com.ymatou.iapi.userservice.testcase;

import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.ymatou.iapi.userservice.parameter.UserBillsRequestDtoBean;
import com.ymatou.iapi.userservice.parameter.req.CreateUserReq;
import com.ymatou.iapi.userservice.service.GUserBillsRequestDtoCall;
import com.ymatou.iapi.userservice.service.UserBillsRequestDtoCall;
import com.ymt.base.YmatouEasyCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.JUserCallService;
import com.ymttest.database.mongo.LoginIdUpdateEventHistoryMongoWapper;
import com.ymttest.database.mongo.ULC201406Bean;
import com.ymttest.database.mongo.ULC201406Wapper;
import com.ymttest.database.sqlwapper.YmtUsersWapper;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.constant.ECode;

/**
*用户凭据更新请求接口
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GUserBillsRequestDto{
	private static UserBillsRequestDtoBean userbillsrequestdtoBean;
	private static GUserBillsRequestDtoCall userbillsrequestdtoCall;
	private static ULC201406Wapper ulcWapper;
	private static String loginId;
	private static String email;
	private static String mobile;
	private static String tradingPas;
	private static String userPas;
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("用户凭据查询请求接口");
	}

	@Before
	public void caseUp() throws Exception {
		userbillsrequestdtoBean=new UserBillsRequestDtoBean();
		userbillsrequestdtoCall=new GUserBillsRequestDtoCall();
		ulcWapper = new ULC201406Wapper();
	}

	@AfterClass
	public static void tearDown() throws Throwable {
		Logger.generateResult(userbillsrequestdtoCall.getOpurl());
		ulcWapper.close();
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GUserBillsRequestDto_001() {
		Logger.start(true,"查询用户信息JIRACONN-3265");
		try {
			CreateUserReq cur=new CreateUserReq();
			cur=JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			//TODO 添加交易密码
			userbillsrequestdtoBean.setUserId(uid);
			userbillsrequestdtoCall.setData(FormatUtil.beanToHttpString(userbillsrequestdtoBean, true, false));
			userbillsrequestdtoCall.callService();
			Logger.verifyEquals("true", userbillsrequestdtoCall.getString("Success"), "验证请求是否成功");
			 JsonObject re = userbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject();
			Logger.verifyEquals(uid,re.get("UserId").getAsInt(), "验证UserId");
			Logger.verifyEquals(cur.getLoginId(),re.get("LoginId").getAsString(), "验证LoginId");
			Logger.verifyEquals(cur.getMobile(),re.get("LoginMobile").getAsString(), "验证LoginMobile");
			Logger.verifyEquals(cur.getMail(),re.get("LoginMail").getAsString(), "验证LoginMail");
			Logger.verifyNotNull(userbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject().get("TPas"), "获取T非空");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GUserBillsRequestDto_002() {
		Logger.start(true,"查询用户信息loginid");
		try {
			CreateUserReq cur=new CreateUserReq();
			cur=JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			//TODO 添加交易密码
			userbillsrequestdtoBean.setLoginId(cur.getLoginId());
			userbillsrequestdtoCall.setData(FormatUtil.beanToHttpString(userbillsrequestdtoBean, true, false));
			userbillsrequestdtoCall.callService();
			Logger.verifyEquals("true", userbillsrequestdtoCall.getString("Success"), "验证请求是否成功");
			 JsonObject re = userbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject();
			Logger.verifyEquals(uid,re.get("UserId").getAsInt(), "验证UserId");
			Logger.verifyEquals(cur.getLoginId(),re.get("LoginId").getAsString(), "验证LoginId");
			Logger.verifyEquals(cur.getMobile(),re.get("LoginMobile").getAsString(), "验证LoginMobile");
			Logger.verifyEquals(cur.getMail(),re.get("LoginMail").getAsString(), "验证LoginMail");
			Logger.verifyNotNull(userbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject().get("TPas"), "获取T非空");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GUserBillsRequestDto_003() {
		Logger.start(true,"查询用户信息mobile");
		try {
			CreateUserReq cur=new CreateUserReq();
			cur=JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			//TODO 添加交易密码
			userbillsrequestdtoBean.setMobile(cur.getMobile());
			userbillsrequestdtoCall.setData(FormatUtil.beanToHttpString(userbillsrequestdtoBean, true, false));
			userbillsrequestdtoCall.callService();
			Logger.verifyEquals("true", userbillsrequestdtoCall.getString("Success"), "验证请求是否成功");
			 JsonObject re = userbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject();
			Logger.verifyEquals(uid,re.get("UserId").getAsInt(), "验证UserId");
			Logger.verifyEquals(cur.getLoginId(),re.get("LoginId").getAsString(), "验证LoginId");
			Logger.verifyEquals(cur.getMobile(),re.get("LoginMobile").getAsString(), "验证LoginMobile");
			Logger.verifyEquals(cur.getMail(),re.get("LoginMail").getAsString(), "验证LoginMail");
			Logger.verifyNotNull(userbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject().get("TPas"), "获取T非空");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GUserBillsRequestDto_004() {
		Logger.start(true,"密码查询用户信息JIRACONN-3265");
		try {
			CreateUserReq cur=new CreateUserReq();
			cur=JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			//TODO 添加交易密码
			userbillsrequestdtoBean.setUserId(uid);
			userbillsrequestdtoBean.setLoginPassword(cur.getLoginPassword());
			userbillsrequestdtoCall.setData(FormatUtil.beanToHttpString(userbillsrequestdtoBean, true, false));
			userbillsrequestdtoCall.callService();
			Logger.verifyEquals("true", userbillsrequestdtoCall.getString("Success"), "验证请求是否成功");
			 JsonObject re = userbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject();
			Logger.verifyEquals(uid,re.get("UserId").getAsInt(), "验证UserId");
			Logger.verifyEquals(cur.getLoginId(),re.get("LoginId").getAsString(), "验证LoginId");
			Logger.verifyEquals(cur.getMobile(),re.get("LoginMobile").getAsString(), "验证LoginMobile");
			Logger.verifyEquals(cur.getMail(),re.get("LoginMail").getAsString(), "验证LoginMail");
			Logger.verifyNotNull(userbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject().get("TPas"), "获取T非空");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GUserBillsRequestDto_005() {
		Logger.start(true,"密码查询用户信息loginid");
		try {
			CreateUserReq cur=new CreateUserReq();
			cur=JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			//TODO 添加交易密码
			userbillsrequestdtoBean.setLoginId(cur.getLoginId());
			userbillsrequestdtoBean.setLoginPassword(cur.getLoginPassword());
			userbillsrequestdtoCall.setData(FormatUtil.beanToHttpString(userbillsrequestdtoBean, true, false));
			userbillsrequestdtoCall.callService();
			Logger.verifyEquals("true", userbillsrequestdtoCall.getString("Success"), "验证请求是否成功");
			 JsonObject re = userbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject();
			Logger.verifyEquals(uid,re.get("UserId").getAsInt(), "验证UserId");
			Logger.verifyEquals(cur.getLoginId(),re.get("LoginId").getAsString(), "验证LoginId");
			Logger.verifyEquals(cur.getMobile(),re.get("LoginMobile").getAsString(), "验证LoginMobile");
			Logger.verifyEquals(cur.getMail(),re.get("LoginMail").getAsString(), "验证LoginMail");
			Logger.verifyNotNull(userbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject().get("TPas"), "获取T非空");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GUserBillsRequestDto_006() {
		Logger.start(true,"密码查询用户信息mobile");
		try {
			CreateUserReq cur=new CreateUserReq();
			cur=JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			//TODO 添加交易密码
			userbillsrequestdtoBean.setMobile(cur.getMobile());
			userbillsrequestdtoBean.setLoginPassword(cur.getLoginPassword());
			userbillsrequestdtoCall.setData(FormatUtil.beanToHttpString(userbillsrequestdtoBean, true, false));
			userbillsrequestdtoCall.callService();
			Logger.verifyEquals("true", userbillsrequestdtoCall.getString("Success"), "验证请求是否成功");
			 JsonObject re = userbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject();
			Logger.verifyEquals(uid,re.get("UserId").getAsInt(), "验证UserId");
			Logger.verifyEquals(cur.getLoginId(),re.get("LoginId").getAsString(), "验证LoginId");
			Logger.verifyEquals(cur.getMobile(),re.get("LoginMobile").getAsString(), "验证LoginMobile");
			Logger.verifyEquals(cur.getMail(),re.get("LoginMail").getAsString(), "验证LoginMail");
			Logger.verifyNotNull(userbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject().get("TPas"), "获取T非空");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GUserBillsRequestDto_007() {
		Logger.start(false,"错误密码查询用户信息失败");
		try {
			CreateUserReq cur=new CreateUserReq();
			cur=JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			//TODO 添加交易密码
			userbillsrequestdtoBean.setUserId(uid);
			userbillsrequestdtoBean.setLoginPassword(cur.getLoginPassword()+1);
			userbillsrequestdtoCall.setData(FormatUtil.beanToHttpString(userbillsrequestdtoBean, true, false));
			userbillsrequestdtoCall.callService();
			Logger.verifyEquals("false", userbillsrequestdtoCall.getString("Success"), "验证请求是否成功");
			Logger.verifyEquals("100003", userbillsrequestdtoCall.getString("ResponseCode"), "验证ResponseCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GUserBillsRequestDto_008() {
		Logger.start(false,"错误密码查询用户信息loginid,失败");
		try {
			CreateUserReq cur=new CreateUserReq();
			cur=JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			userbillsrequestdtoBean.setLoginId(cur.getLoginId());
			userbillsrequestdtoBean.setLoginPassword(cur.getLoginPassword()+1);
			userbillsrequestdtoCall.setData(FormatUtil.beanToHttpString(userbillsrequestdtoBean, true, false));
			userbillsrequestdtoCall.callService();
			Logger.verifyEquals("false", userbillsrequestdtoCall.getString("Success"), "验证请求是否成功");
			Logger.verifyEquals("100003", userbillsrequestdtoCall.getString("ResponseCode"), "验证ResponseCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GUserBillsRequestDto_009() {
		Logger.start(false,"错误密码查询用户信息mobile,失败");
		try {
			CreateUserReq cur=new CreateUserReq();
			cur=JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			userbillsrequestdtoBean.setMobile(cur.getMobile());
			userbillsrequestdtoBean.setLoginPassword(cur.getLoginPassword()+1);
			userbillsrequestdtoCall.setData(FormatUtil.beanToHttpString(userbillsrequestdtoBean, true, false));
			userbillsrequestdtoCall.callService();
			Logger.verifyEquals("false", userbillsrequestdtoCall.getString("Success"), "验证请求是否成功");
			Logger.verifyEquals("100003", userbillsrequestdtoCall.getString("ResponseCode"), "验证ResponseCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GUserBillsRequestDto_010() {
		Logger.start(false,"未查询到用户,失败");
		try {
//			userbillsrequestdtoBean.setMobile(cur.getMobile());
//			userbillsrequestdtoBean.setLoginPassword(cur.getLoginPassword()+1);
			userbillsrequestdtoCall.setData(FormatUtil.beanToHttpString(userbillsrequestdtoBean, true, false));
			userbillsrequestdtoCall.callService();
			Logger.verifyEquals("false", userbillsrequestdtoCall.getString("Success"), "验证请求是否成功");
			Logger.verifyEquals("100001", userbillsrequestdtoCall.getString("ResponseCode"), "验证ResponseCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GUserBillsRequestDto_011() {
		Logger.start(false,"不存在用户uid,失败");
		try {
			userbillsrequestdtoBean.setUserId(-1);
//			userbillsrequestdtoBean.setLoginPassword(cur.getLoginPassword()+1);
			userbillsrequestdtoCall.setData(FormatUtil.beanToHttpString(userbillsrequestdtoBean, true, false));
			userbillsrequestdtoCall.callService();
			Logger.verifyEquals("false", userbillsrequestdtoCall.getString("Success"), "验证请求是否成功");
			Logger.verifyEquals("100001", userbillsrequestdtoCall.getString("ResponseCode"), "验证ResponseCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GUserBillsRequestDto_012() {
		Logger.start(false,"不存在用户Loginid,失败");
		try {
			userbillsrequestdtoBean.setLoginId("notfound404");
//			userbillsrequestdtoBean.setLoginPassword(cur.getLoginPassword()+1);
			userbillsrequestdtoCall.setData(FormatUtil.beanToHttpString(userbillsrequestdtoBean, true, false));
			userbillsrequestdtoCall.callService();
			Logger.verifyEquals("false", userbillsrequestdtoCall.getString("Success"), "验证请求是否成功");
			Logger.verifyEquals("100001", userbillsrequestdtoCall.getString("ResponseCode"), "验证ResponseCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GUserBillsRequestDto_013() {
		Logger.start(false,"不存在用户Mobile,失败");
		try {
			userbillsrequestdtoBean.setMobile("notfound404");
//			userbillsrequestdtoBean.setLoginPassword(cur.getLoginPassword()+1);
			userbillsrequestdtoCall.setData(FormatUtil.beanToHttpString(userbillsrequestdtoBean, true, false));
			userbillsrequestdtoCall.callService();
			Logger.verifyEquals("false", userbillsrequestdtoCall.getString("Success"), "验证请求是否成功");
			Logger.verifyEquals("100001", userbillsrequestdtoCall.getString("ResponseCode"), "验证ResponseCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GUserBillsRequestDto_014() {
		Logger.start(true,"Mail查询用户信息");
		try {
			CreateUserReq cur=new CreateUserReq();
			cur=JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			//TODO 添加交易密码
			userbillsrequestdtoBean.setMail(cur.getMail());
			userbillsrequestdtoCall.setData(FormatUtil.beanToHttpString(userbillsrequestdtoBean, true, false));
			userbillsrequestdtoCall.callService();
			Logger.verifyEquals("true", userbillsrequestdtoCall.getString("Success"), "验证请求是否成功");
			 JsonObject re = userbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject();
			Logger.verifyEquals(uid,re.get("UserId").getAsInt(), "验证UserId");
			Logger.verifyEquals(cur.getLoginId(),re.get("LoginId").getAsString(), "验证LoginId");
			Logger.verifyEquals(cur.getMobile(),re.get("LoginMobile").getAsString(), "验证LoginMobile");
			Logger.verifyEquals(cur.getMail(),re.get("LoginMail").getAsString(), "验证LoginMail");
			Logger.verifyNotNull(userbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject().get("TPas"), "获取T非空");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GUserBillsRequestDto_015() {
		Logger.start(true,"Mail+密码查询用户信息");
		try {
			CreateUserReq cur=new CreateUserReq();
			cur=JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			//TODO 添加交易密码
			userbillsrequestdtoBean.setMail(cur.getMail());
			userbillsrequestdtoBean.setLoginPassword(cur.getLoginPassword());
			userbillsrequestdtoCall.setData(FormatUtil.beanToHttpString(userbillsrequestdtoBean, true, false));
			userbillsrequestdtoCall.callService();
			Logger.verifyEquals("true", userbillsrequestdtoCall.getString("Success"), "验证请求是否成功");
			 JsonObject re = userbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject();
			Logger.verifyEquals(uid,re.get("UserId").getAsInt(), "验证UserId");
			Logger.verifyEquals(cur.getLoginId(),re.get("LoginId").getAsString(), "验证LoginId");
			Logger.verifyEquals(cur.getMobile(),re.get("LoginMobile").getAsString(), "验证LoginMobile");
			Logger.verifyEquals(cur.getMail(),re.get("LoginMail").getAsString(), "验证LoginMail");
			Logger.verifyNotNull(userbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject().get("TPas"), "获取T非空");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GUserBillsRequestDto_016() {
		Logger.start(false,"不存在用户mail,失败");
		try {
			userbillsrequestdtoBean.setMail("notfound404");
//			userbillsrequestdtoBean.setLoginPassword(cur.getLoginPassword()+1);
			userbillsrequestdtoCall.setData(FormatUtil.beanToHttpString(userbillsrequestdtoBean, true, false));
			userbillsrequestdtoCall.callService();
			Logger.verifyEquals("false", userbillsrequestdtoCall.getString("Success"), "验证请求是否成功");
			Logger.verifyEquals("100001", userbillsrequestdtoCall.getString("ResponseCode"), "验证ResponseCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GUserBillsRequestDto_017() {
		Logger.start(false,"错误密码查询用户信息mail,失败");
		try {
			CreateUserReq cur=new CreateUserReq();
			cur=JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			userbillsrequestdtoBean.setMail(cur.getMail());
			userbillsrequestdtoBean.setLoginPassword(cur.getLoginPassword()+1);
			userbillsrequestdtoCall.setData(FormatUtil.beanToHttpString(userbillsrequestdtoBean, true, false));
			userbillsrequestdtoCall.callService();
			Logger.verifyEquals("false", userbillsrequestdtoCall.getString("Success"), "验证请求是否成功");
			Logger.verifyEquals("100003", userbillsrequestdtoCall.getString("ResponseCode"), "验证ResponseCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GUserBillsRequestDto_018() {
		Logger.start(true,"密码查询用户信息loginid,密码带特殊字符");
		try {
			CreateUserReq cur=new CreateUserReq();
			cur=JUserCallService.initCreateUserBean(cur);
			cur.setLoginPassword("1qaz@WSX");
			int uid = JUserCallService.createUserCall(cur);
			//TODO 添加交易密码
			userbillsrequestdtoBean.setLoginId(cur.getLoginId());
			userbillsrequestdtoBean.setLoginPassword(cur.getLoginPassword());
			userbillsrequestdtoCall.setData(FormatUtil.beanToHttpString(userbillsrequestdtoBean, true, false));
			userbillsrequestdtoCall.callService();
			Logger.verifyEquals("true", userbillsrequestdtoCall.getString("Success"), "验证请求是否成功");
			 JsonObject re = userbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject();
			Logger.verifyEquals(uid,re.get("UserId").getAsInt(), "验证UserId");
			Logger.verifyEquals(cur.getLoginId(),re.get("LoginId").getAsString(), "验证LoginId");
			Logger.verifyEquals(cur.getMobile(),re.get("LoginMobile").getAsString(), "验证LoginMobile");
			Logger.verifyEquals(cur.getMail(),re.get("LoginMail").getAsString(), "验证LoginMail");
			Logger.verifyNotNull(userbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject().get("TPas"), "获取T非空");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}